<?
session_start();

include('./../config/db_settings.php');
include('./../pms/pms_inc.php');

if(mysql_error()==""){
	$user = trim(urldecode($_POST['name']));
	if(strlen($user)==0){
		echo "<b>Please enter a user name.</b><br>";
		exit;
	}

	$sql = mysql_query ("SELECT count(*) user_count FROM ".$db_settings['userdata_table']." WHERE lower(user_name) = '".mysql_real_escape_string(strtolower($user))."'");
	$row = mysql_fetch_array ($sql);
	$user_count = $row['user_count'];
	if($user_count==0){
		$msg = "Congrats! User name <b>".$user."</b> is available.<br/>";
	}else{
		$msg = "Sorry, user name <b>".$user."</b> is not available. Please choose another user name.<br/>";
	}
	echo $msg;

}else
{
	echo "Sorry, there is a database error.";
}

?>

